<html>
<head>
	<title>Insert Link</title>
	<script type="text/javascript" src="../prototype.js" ></script>
	<link type="text/css" rel="stylesheet" href="../themes/office12/style.css" />
<body>
	<form>

		<textarea id="CodeText" style="width:400px; height: 200px; wrap:none;"></textarea>
		
		<br />		
		
		<input type="submit" id="SubmitLink" value="Insert Code" class="langRec" recKey="insertcode" /> 
	</form>
	

<script type="text/javascript">	

Event.observe(window,'load',init);
Event.observe('SubmitLink','click',submitLink);
Event.observe(document.getElementsByTagName('form')[0],'submit',submitLink);

var ftb;
var refresh;

function init() {

	if (window.opener)
		refresh = window.opener.Refresh;
	else
		refresh = window.parent.Refresh;
	
	ftb = refresh.Web.CurrentFreeTextBox;
	if (ftb == null) ftb = refresh.Web.FreeTextBoxList[0];

	// set language 
	refresh.Web.Localization.updateLanguageElements(document, ftb.options.language);
}
function submitLink(event) {
	Event.stop(event);

	var code = $F('CodeText');
	
	code = code.replace(/\t/g,'&nbsp;&nbsp;&nbsp;&nbsp;').replace(/\n/g,'<br />');
	
	ftb.insertHtml(code);
	
	refresh.Web.ModalWindow.hide();
	window.close();
}
</script>
</body>
</html>